<template>
  <div>
    <el-container>
      <el-header>
        <div class="wf-top-left clear">
          <i class="el-icon-s-fold i-icon" @click="Fold"></i>
          <h2>易理赔</h2>
        </div>
        <div class="wf-top-right clear">
          <el-dropdown @command="handleCommand">
            <el-button type="primary">
              {{ username }}<i class="el-icon-arrow-down el-icon--right"></i>
            </el-button>
            <el-dropdown-menu slot="dropdown" split-button>
              <el-dropdown-item command="loginOut">退出登录</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </div>
      </el-header>
      <el-container>
        <el-aside
          width="200px"
          :style="{ height: mainHeight + 'px' }"
          v-show="isFold"
        >
          <SideBar></SideBar>
        </el-aside>
        <el-main :style="{ height: mainHeight + 'px' }" class="wf-main">
          <router-view v-show="$route.meta.showFooter"> </router-view>
        </el-main>
      </el-container>
      <el-footer>@易理赔后台管理 版权所有 2018-现在  增值电信业务经营许可证：浙B2-20070195 <img src="https://gw.alicdn.com/tfs/TB1jwakrbH1gK0jSZFwXXc7aXXa-20-20.png"> 浙公网安备 33010002000075号</el-footer>
    </el-container>
  </div>
</template>
<script>
import { mapActions } from "vuex";
import SideBar from "../components/SideBar.vue";

export default {
  data() {
    return {
      isFold: true,
      username: localStorage.getItem("username"),
    };
  },
  components: {
    SideBar,
  },
  methods: {
    ...mapActions(["userStore/logoutAction", "userStore/authorityAction"]),
    handleCommand(command) {
      if (command == "loginOut") {
        this["userStore/logoutAction"]()
          .then(() => {
            this.$router.push("/login");
            this.$message({
              message: "退出成功",
              type: "success",
            });
            // console.log("退出成功");
          })
          .catch((err) => {
            this.$message({
              message: "退出失败",
            });
            console.log("退出失败", err);
          });
      }
    },
    handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    },
    Fold() {
      this.isFold = !this.isFold;
      // console.log(this.isFold);
    },
  },
  created() {
    const h = window.innerHeight;
    this.mainHeight = h - 121;
  },
};
</script>
<style lang="scss" scoped>
.el-header,
.el-footer {
  background-color: #b3c0d1;
  color: #333;
  text-align: center;
  line-height: 60px;
}

.el-aside {
  background-color: rgb(255, 255, 255);
  color: #333;
  text-align: left;
  line-height: 200px;

  &::-webkit-scrollbar {
    display: none;
  }
}

.el-main {
  background-color: #e9eef3;
  color: #333;
  min-width: 1000px;
}

body > .el-container {
  margin-bottom: 40px;
}

.el-container:nth-child(5) .el-aside,
.el-container:nth-child(6) .el-aside {
  line-height: 260px;
}

.el-container:nth-child(7) .el-aside {
  line-height: 320px;
}
.wf-top-left {
  float: left;

  i {
    float: left;
    line-height: 60px;
    font-size: 30px;
    margin-right: 10px;
  }
  h2 {
    float: left;
  }
}
.wf-top-right {
  float: right;
}
</style>